package org.github.manx98.jlibhac.tools.fssystem.romfs;

import org.github.manx98.jlibhac.fs.IStorage;
import org.github.manx98.jlibhac.fs.fsa.IFile;
import org.github.manx98.jlibhac.fs.fsa.OpenMode;

import java.io.IOException;

/**
 * @author Manx98
 * @version 1.0
 * @since 2022/10/5 14:15
 */
public class RomFsFile extends IFile {
    private final long offset;
    private final long length;
    private final IStorage baseStorage;

    public RomFsFile(IStorage baseStorage, long offset, long length) {
        super(0);
        this.offset = offset;
        this.length = length;
        this.baseStorage = baseStorage;
    }

    @Override
    public void read(long offset, byte[] destination, int destOffset, int len) throws IOException {
        baseStorage.read(this.offset + offset, destination, destOffset, len);
    }

    @Override
    public long getSize() {
        return length;
    }
}
